Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] VX-233 johnlin/resource createdby #204

Merged
merged 43 commits into from
Aug 23, 2018
Merged

Conversation

John-Lin
Copy link
Contributor

No description provided.

@John-Lin John-Lin changed the title [task] VX-233 johnlin/resource createdby [Task] VX-233 johnlin/resource createdby Jul 30, 2018
@codecov-io
Copy link

codecov-io commented Jul 30, 2018

Codecov Report

Merging #204 into develop will increase coverage by <.01%.
The diff coverage is 67.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #204      +/-   ##
===========================================
+ Coverage    78.57%   78.57%   +<.01%     
===========================================
  Files           59       60       +1     
  Lines         3300     3361      +61     
===========================================
+ Hits          2593     2641      +48     
- Misses         540      547       +7     
- Partials       167      173       +6
Impacted Files Coverage Δ
src/networkprovider/ovs_system.go 77.77% <ø> (+4.09%) ⬆️
src/networkprovider/ovs_netdev.go 64.7% <ø> (+2.44%) ⬆️
src/server/backend/user.go 0% <0%> (ø)
src/server/backend/authenticate.go 83.33% <100%> (ø) ⬆️
src/server/backend/jwt.go 100% <100%> (ø) ⬆️
src/server/route.go 84.67% <100%> (+0.51%) ⬆️
src/server/handler_volume.go 68.68% <62.5%> (-0.55%) ⬇️
src/server/handler_network.go 71.33% <66.66%> (-0.29%) ⬇️
src/server/handler_service.go 70.94% <66.66%> (-0.36%) ⬇️
src/server/handler_pod.go 69.16% <66.66%> (-0.21%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf50cfa...e2dbc66. Read the comment docs.

@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch 3 times, most recently from 39237b1 to 2ac5683 Compare July 31, 2018 07:38
return
}
}
network.CreatedBy = user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一般是不是都存ID之類的,需要存到整個entity嗎?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要,這樣比較有效率 不用再多打一次 user api

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這樣如果user可以修改任何欄位的話,就會造成資訊不對等

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同時若有user被刪除,你從這邊不能知道他被刪除

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我們大部分操作都不會很大量的需求所以這邊的mongo lookuuup 應該沒太大的效能問題

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user 不能修改id. 這個有跟前端討論過,主要是前端 query 的方式,多打一次user前端邏輯變得複雜

//init session
suite.session = sp.Mongo.NewSession()
//init restful container
suite.wc = restful.NewContainer()
service := newNetworkService(sp)
suite.wc.Add(service)

suite.sp = sp
token, _ := loginGetToken(suite.sp, suite.wc)
suite.JWTBearer = "Bearer " + token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空一格是故意的嗎?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這是他的header規則

Authorization: Bearer <token>

if v == 0 && failedDropTestDatabase() {
os.Exit(1)
}
os.Exit(v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

沒有處理v!=0時的db drop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我後來想一下 failedDropTestDatabase 都會跑到即使是 v!=0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

真怪,按照 short circult最佳化,應該前面false, 後面就不會跑了?

另外,如果testing都如預料以及預期,成功跑完不需要清空 mongo.因為 testing本身就要清除乾淨

@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch 4 times, most recently from 01beba8 to a7fc589 Compare August 7, 2018 03:31
@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch from a7fc589 to 0d277c7 Compare August 8, 2018 12:25
@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch 2 times, most recently from 14f3b1a to 3bfe35e Compare August 17, 2018 03:04
@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch 4 times, most recently from 57f09d0 to fe3b024 Compare August 22, 2018 10:11
@John-Lin
Copy link
Contributor Author

John-Lin commented Aug 22, 2018

using $lookup to aggregate data

for example

db.users.insert({"_id":1,"username":"john"})
db.users.insert({"_id":2,"username":"john2"})
db.users.insert({"_id":3,"username":"yoyo"})
db.users.insert({"_id":4,"username":"yoyo2"})


db.networks.insert({"_id":1,"uid":3,"networkName":"yoyo-net"})
db.networks.insert({"_id":2,"uid":2,"networkName":"john-net2"})
db.networks.insert({"_id":3,"uid":1,"networkName":"john-net"})
db.networks.insert({"_id":4,"uid":4,"networkName":"yoyo-net2"})


db.networks.aggregate([
    {
      $lookup:
        {
          from: "users",
          localField: "uid",
          foreignField: "_id",
          as: "users_docs"
        }
   }
])


db.networks.aggregate([
    {
      $lookup:
        {
          from: "users",
          localField: "uid",
          foreignField: "_id",
          as: "users_docs"
        }
   },
   { $match : { _id : 3 } }
])

@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch from 58a4825 to 1b5dca1 Compare August 23, 2018 08:43
@John-Lin John-Lin force-pushed the johnlin/resource-createdby branch from 1b5dca1 to e2dbc66 Compare August 23, 2018 08:52
@John-Lin John-Lin removed the pending label Aug 23, 2018
@John-Lin
Copy link
Contributor Author

John-Lin commented Aug 23, 2018

還剩下 deployment, app, namespace, storage, user 尚未做auth

@John-Lin John-Lin merged commit c1139da into develop Aug 23, 2018
@John-Lin John-Lin deleted the johnlin/resource-createdby branch August 23, 2018 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants